package com.lagou.edu.client;

import com.lagou.edu.demo1.IHelloService;
import com.lagou.edu.pojo.User;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

public class RMIClient {
    public static void main(String[] args) throws RemoteException, NotBoundException, MalformedURLException {
        // 1. 从注册表中获取远程对象，强转
        IHelloService service = (IHelloService) Naming.lookup("//127.0.0.1:8888/rmiserver");

        // 2. 准备参数
        User user = new User("laowang", 18);

        // 3. 调用远程方法sayHello
        String me = service.sayHello(user);
        System.out.println(me);
    }
}
